from data.classifier_model import ClsModel
from data.classifier_modelB import ClsModelB


def model_train(classifier_model_list,data,target,epoch,record_fn,record_file_path):
    for e in range(epoch):
        for c in classifier_model_list:
            # 90%作为训练集
            modelA = ClsModel(c)
            modelA.train_test_split(data,target,test_size=0.1,random_state=42)
            # 模型训练
            modelA.train()
            # 计算参数
            modelA.evaluate_all()
            record_fn(record_file_path,modelA.get_xlsx_data())
            modelA.print_metrics()
            modelA.save_model()

            modelB = ClsModelB(c)
            # 模型A训练集再切分
            modelB.train_test_split(modelA.get_x_train(),modelA.get_y_train())
            modelB.train()
            # 使用模型A的 测试集
            modelB.evaluate_all(modelA.get_x_test(),modelA.get_y_test())
            record_fn(record_file_path,modelB.get_xlsx_data())
            modelB.print_metrics()
            modelB.save_model()
